package edu.must.uh.Filter;

import javax.servlet.http.HttpServletRequest;
import com.alibaba.fastjson.JSON;
import edu.must.uh.util.CookieUtil;
import edu.must.uh.util.JedisUtil;
import edu.must.uh.util.Tools;

public  class LoginUserHelper {
    
    public static User getLoginUser(HttpServletRequest request) {        
        String  cookiesUser = CookieUtil.getUid((HttpServletRequest)request, "LoginUser");
        if(Tools.notEmpty(cookiesUser)) {
            String  LoginUser = JedisUtil.get("LoginUser",cookiesUser);  
            User user = JSON.parseObject(LoginUser, User.class);
            return user;
        }
        return null;      
    }
    
    
    public static String getLoginUserid(HttpServletRequest request) {        
        String  cookiesUser = CookieUtil.getUid((HttpServletRequest)request, "LoginUser");
        if(Tools.notEmpty(cookiesUser)) {
            String  LoginUser = JedisUtil.get("LoginUser",cookiesUser);  
            User user = JSON.parseObject(LoginUser, User.class);
            return user.getUserId();
        }
        return "";      
    }
    

}
